package com.softer.chengxin.excel.controller;

import com.softer.chengxin.common.domin.Common;
import com.softer.chengxin.excel.service.ExcelStreetService;
import com.softer.chengxin.home.domin.Street;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Gong Zhiyang
 * @date 2019/2/19
 */
@RestController
@RequestMapping("/api/excel")
public class ExcelStreetController {
    @Autowired
    private ExcelStreetService excelStreetService;

    /**
     * 报表功能中
     * 获取地区下拉列表
     *
     * @param session 缓存
     * @return 地区列表
     */
    @PostMapping("/getExcelStreet")
    public List<Street> getExcelStreet(HttpSession session) {
        //  查询登陆ID
        Integer id = (Integer) session.getAttribute(Common.ID);
        if (id == null) {
            return new ArrayList<>();
        }
        return excelStreetService.getExcelStreet(id);
    }
}
